package treeedit;

import java.awt.Color;
import java.awt.Component;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.border.BevelBorder;
import javax.swing.tree.DefaultTreeCellRenderer;

public class CodeRendererExtra extends CodeRenderer 
{
	LookManager lookManager = LookManager.getInstance();
	@Override
	public Component getTreeCellRendererComponent(JTree arg0, Object node, boolean arg2, boolean expanded, boolean arg4, int arg5, boolean arg6) {
		
		JLabel l = (JLabel)super.getTreeCellRendererComponent(arg0, node, arg2, expanded, arg4, arg5,
				arg6);
		
		CodeNode n = (CodeNode) node;
		
//		System.out.println("Node " + n.getRepresentation() + " string=" + n.isString() + " function=" + n.isFunction());
		
		if(n.isMarked())
		{
			lookManager.getMarkedLabel(l);
		}
		else if (n.isString())
		{
			lookManager.getStringLabel(l);
		}
		else if(n.isFunction())
		{
			lookManager.getFunctionLabel(l);
		}
		else
		{
			lookManager.getNormalLabel(l);
		}
		
		
		if(expanded)
			l.setText(n.getRepresentation().toLowerCase());
		else 
			l.setText(n.getShortcut().toLowerCase());
		 
		
		return l;
	}
}
